package com.hsq.end_of_period;

public class TestRectangle {
    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle(10, 5);
        System.out.println(rectangle.getArea());
        System.out.println(rectangle.getPerimeter());
        rectangle.draw();
        System.out.println(rectangle);
    }
}

class Rectangle {
    int width;
    int high;
    public Rectangle(int width, int high) {
        this.width = width;
        this.high = high;
    }

    public int getArea() {
        return width * high;
    }

    public int getPerimeter() {
        return 2 * (width + high);
    }

    void draw() {
        for (int i = 1; i <= high; i++) {
            if (i == 1 || i == high) {
                for (int j = 1; j <= width; j ++) {
                    System.out.print("* ");
                }
            }else {
                for (int j = 1; j <= width; j ++){
                    if (j==1 || j == width){
                        System.out.print("* ");
                    }else {
                        System.out.print("  ");
                    }
                }
            }
            System.out.println();
        }
    }

    @Override
    public String toString() {
        return "Rectangle{" +
                "width=" + width +
                ", high=" + high +
                '}';
    }
}

